/*
 * Copyright© 2003-2019 浙江汇信科技有限公司, All Rights Reserved.
 */
package com.icinfo.cloud.provider.punish.execute.controller;

import com.icinfo.cloud.provider.punish.approval.dto.AuditDetailDocumentQueryDto;
import com.icinfo.cloud.provider.punish.approval.vo.AuditInfoChainLogTopVo;
import com.icinfo.cloud.provider.punish.approval.vo.AuditInfoChainLogVo;
import com.icinfo.cloud.provider.punish.execute.service.IExecuteDocumentRecordService;
import com.icinfo.framework.common.web.Result;
import com.icinfo.framework.core.web.BaseController;
import io.swagger.annotations.ApiOperation;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.text.ParseException;
import java.util.List;

/**
 * 描述: 裁执分离文书记录表 execute_document_record 对应的Controller类.<br>
 *
 * @author framework generator
 * @date 2022年08月26日
 */
@RestController
@RequestMapping("/executeDocument")
public class ExecuteDocumentRecordController extends BaseController {
    /**
     * 日志记录器
     */
    private static final Logger logger = LoggerFactory.getLogger(ExecuteDocumentRecordController.class);

    @Resource
    private IExecuteDocumentRecordService executeDocumentRecordService;

    /**
     * 描述: 裁执分离查询审批链头部信息
     *
     * @param auditDetailDocumentQueryDto
     * @return com.icinfo.framework.common.web.Result
     * @author zhanghongqiang
     * @Date 2022/9/7
     */
    @PostMapping("/readAuditChainTop")
    @ApiOperation(value = "裁执分离查询审批链头部信息", httpMethod = "POST")
    public Result<AuditInfoChainLogTopVo> readAuditChainTop(@Validated @RequestBody AuditDetailDocumentQueryDto auditDetailDocumentQueryDto) {
        // 查询当前审批表关联流程的完整审批流
        // 查询 已审批表和待审批表 最后拼接 最后审批角色名
        return Result.success("success", executeDocumentRecordService.getAuditChainTop(auditDetailDocumentQueryDto));
    }

    /**
     * 描述: 查询审批链日志
     *
     * @param auditDetailDocumentQueryDto
     * @return com.icinfo.framework.common.web.Result
     * @author zhanghongqiang
     * @Date 2022/9/7
     */
    @PostMapping("/readAuditChain")
    @ApiOperation(value = "查询审批链日志", httpMethod = "POST")
    public Result<List<AuditInfoChainLogVo>> readAuditChain(@Validated @RequestBody AuditDetailDocumentQueryDto auditDetailDocumentQueryDto) throws ParseException {
        // 查询当前审批表关联流程的完整审批流
        // 查询 已审批表和待审批表 最后拼接 最后审批角色名
        List<AuditInfoChainLogVo> list = executeDocumentRecordService.getAuditChain(auditDetailDocumentQueryDto);
        return Result.success("success", list);
    }
}